<template>
  <div>
    <navTop />
    <div class="fenleiDet-content">
      <div class="list-tab">
        <router-link v-for="(item,index) in sortType" :key="index" :class="{active:activeIndex==index}" to=""><span @click="changeSort(index)">{{item}}</span></router-link>
      </div>
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import navTop from "@/components/common/navTop"
export default {
  data () {
    return {
      sortType:["新品","销量","评价","价格"],
      activeIndex :""
    }
  },
  components: {
      navTop
  },
  methods: {
    changeSort(index){
      this.activeIndex = index
      this.$store.dispatch("changeSort",index);
    },
  }
}
</script>

<style lang="scss" scoped>
.list-tab{
  width: 100%;
  height: 36px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 22px;
  a{
    color: #575757;
    font-size: 14px;
  }
}
.active{
  color: #b51219!important;
}
</style>